package com.li.util;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CheckUtils {
    @Resource
    private RedisTemplate redisTemplate;
    public boolean checkWithBloomFilter(String checkItem, String key) {
        int hashValue= Math.abs(key.hashCode());
        long index =(long)(hashValue % Math.pow(2,32));
        boolean isExists =redisTemplate.opsForValue().getBit(checkItem,index);
        log.info("key:{}对应的坑位index:{}",key,index+"是否存在:"+isExists);
        return isExists;
    }
}
